
<template>
  <div class="mine_box">
    <topHeader>
      <span slot="center">
        个人中心
      </span>
    </topHeader>
    <div class="mine_box_con">
      <div class="info_box">
        <div class="user_box">
          <div class="left">
            <img src="./../../assets/img/userheader.png" alt="">
          </div>
          <div class="right">
            <p>{{ userInfo.name }}</p>
            <span>{{ userInfo.phone }}</span>
          </div>
        </div>
        <div class="info_bottom">
          <div>
            <p>{{ userInfo.reputation }}分</p>
            <span>诚信值</span>
          </div>
          <div>
            <p>{{ userInfo.money }}元</p>
            <span>我的余额</span>
          </div>
        </div>
      </div>
      <div class="mine_list">
        <div class="mine_list_t">个人中心</div>
        <div class="mine_list_con">
          <div class="moudle" @click="goPage(1)">
            <div class="top_icon">
              <img src="./../../assets/img/peopleshi.png" alt="">
            </div>
            <div class="bottom_title">
                实名认证
            </div>
          </div>
          <div class="moudle" @click="goPage(2)">
            <div class="top_icon">
              <img src="./../../assets/img/carshi.png" alt="">
            </div>
            <div class="bottom_title">
                车主认证
            </div>
          </div>
          <div class="moudle" @click="goPage(3)">
            <div class="top_icon">
              <img src="./../../assets/img/route_1.png" alt="">
            </div>
            <div class="bottom_title">
                我的发布
            </div>
          </div>
          <div class="moudle" @click="goPage(4)">
            <div class="top_icon">
              <img src="./../../assets/img/evelate.png" alt="">
            </div>
            <div class="bottom_title">
                帮助中心
            </div>
          </div>
          <div class="moudle"  @click="goPage(5)">
            <div class="top_icon">
              <img src="./../../assets/img/metting.png" alt="">
            </div>
            <div class="bottom_title">
                我的预约
            </div>
          </div>
          <div class="moudle" @click="goPage(7)">
            <div class="top_icon">
              <img src="./../../assets/img/phone.png" alt="">
            </div>
            <div class="bottom_title">
                修改手机号
            </div>
          </div>
          <div class="moudle" @click="goPage(8)">
            <div class="top_icon">
              <img src="./../../assets/img/people_icon.png" alt="">
            </div>
            <div class="bottom_title">
                修改姓名
            </div>
          </div>
          <div class="moudle" @click="goPage(9)">
            <div class="top_icon">
              <img src="./../../assets/img/help.png" alt="">
            </div>
            <div class="bottom_title">
              客服中心
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* eslint-disable */
import { userIdAuthority, driverIdAuthority, driverCardAuthority } from '@/api/allapis'
import topHeader from './../../components/topHeader'
export default {
  data () {
    return {
      driverAuthority: false,
      driverCardAuthority: false,
    }
  },

  components: {
    topHeader
  },

  computed: {
    userInfo(){
      return this.$store.state.user.uerInfo
    }
  },

  mounted () {
    console.log(this.$store.state.user.uerInfo)
  },

  methods: {
    async goPage (type) {
      if (type === 1) {
        userIdAuthority({ userID: this.$store.state.user.uerInfo.id }).then(res => {
          if (res.data === '身份证未认证') {
            this.$router.push({ name: 'userconfirm' })
          } else {
            this.$vux.alert.show({
              title: '人人同行提示',
              content: '身份证已认证',
              buttonText: '好的',
              hideOnBlur: true,
              maskZIndex: 100
            })
            // alert('身份证已认证')
          }
        })
      } else if (type === 2) {
        await driverIdAuthority({id: this.$store.state.user.uerInfo.id }).then(res => {
          if(res.data === '驾驶证已认证'){
            this.driverAuthority = true
          }
        })
        await driverCardAuthority({id: this.$store.state.user.uerInfo.id }).then(res => {
          if(res.data === '行驶证已认证'){
            this.driverCardAuthority = true
          }
        })
        if(!this.driverAuthority||!this.driverCardAuthority){
          this.$router.push({ name: 'driverconfirm' })
        } else {
          this.$vux.alert.show({
            title: '人人同行提示',
            content: '车主已认证',
            buttonText: '好的',
            hideOnBlur: true,
            maskZIndex: 100
          })
          // alert('车主已认证')
        }
        // this.$router.push({ name: 'driverconfirm' })
      }else if (type === 3) {
        this.$router.push({ name: 'myroute' })
      }else if (type === 4) {
        this.$router.push({ name: 'help' })
      } else if (type === 5) {
        this.$router.push({ name: 'orders' })
      } else if (type === 7) {
        this.$router.push({ name: 'updatetel' })
      }else if (type === 8) {
        this.$router.push({ name: 'updatename' })
      }else if (type === 9) {
        this.$router.push({ name: 'kefu' })
      }
    }
  }
}

</script>
<style lang='less' scoped>
@import url('./mine.less');
</style>